import { type ClassValue, clsx } from "clsx";
import { format } from "date-fns";
import { twMerge } from "tailwind-merge";

export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs));
}

export const formatDate = (date: number): string => {
  return format(new Date(date), "yyyy-MM-dd HH:mm:ss");
};

export function isEmptyObject(obj: object): boolean {
  return !Array.isArray(obj) && Object.keys(obj).length === 0;
}

export function rate(num: number, total: number) {
  return Number(((num * 100) / total).toFixed(2));
}
